package com.zdxc.service;


import com.zdxc.entities.CodeAddress;
import common.bean.Paging;
import common.dao.BaseMyBatisDAO;
import common.util.StringEncrypt;
import common.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

/**
 * 用户服务类
 */
@Lazy
@Service
public class AddressService {
    @Autowired
    BaseMyBatisDAO baseMyBatisDAO;
    private static final String SQL_NS = "com.zdxc.dao.CodeAddress.";

    public Paging findByCondition(CodeAddress addressinfo, Paging paging) {
        paging.setStringParams(addressinfo);

        paging = baseMyBatisDAO.findForPageHelper(SQL_NS + "findByCondition", paging);

        return paging;
    }

    /**
     * 根据addressId查询地点信息
     *
     * @param addressId
     * @return CodeAddress
     */
    public CodeAddress findByKey(String addressId){
        return baseMyBatisDAO.findUnique(SQL_NS +"selectByPrimaryKey", addressId);
    }


    /**
     * 插入用户信息
     * @param addressInfo
     * @return int
     */
    public int insert(CodeAddress addressInfo){
        addressInfo.setAddressId(StringUtils.getUUID()); //生成主键
        return baseMyBatisDAO.insert(SQL_NS +"insertSelective", addressInfo);
    }


    /**
     * 更新用户信息
     *
     */
    public int update(CodeAddress addressinfo)
    {
      int result  =   baseMyBatisDAO.update(SQL_NS+"updateByPrimaryKeySelective",addressinfo);
      return result;
    }

    /**
     * 删除地点信息
     *
     */
    public int deleteByPrimaryKey(String addressId)
    {
        int result  =   baseMyBatisDAO.update(SQL_NS+"deleteByPrimaryKey",addressId);
        return result;
    }



}
